import requests
from flask import Flask,request,  jsonify, abort, make_response
import logging

import os
#import myip
#print(myip.myaddr)
this = os.path.dirname(__file__)
logging.basicConfig(filename=os.path.join(this,'log.txt'), level=logging.INFO,
                    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

app = Flask(__name__)
port = 9090
# 设置中文显示
app.config.update(RESTFUL_JSON=dict(ensure_ascii=False))

#http://0.0.0.0:9090/
@app.route("/")
def hello_world():
    return "<p>Hello, World!</p>"

@app.route("/index")
def index():
    return "<p>index</p>"

@app.route('/direct_return', methods=['GET'])
def direct_return():
    '''
    handle the user query
    :return:
    '''

    print(request.args)
    print('direct return')
    return {'code':0}

# @app.route('/direct_return2', methods=['POST'])
# def direct_return2():
#     '''
#     handle the user query
#     :return:
#     '''
#
#     print("args",request.args)
#     print("json",request.json)
#     print('direct return')
#     return {'code':0}



if __name__ == "__main__":
    app.config["JSON_AS_ASCII"] = False
    DEPLOYEE_ENV = False  #修改
    #     # True 为正式环境
    app.run(host="0.0.0.0", port=port, debug=True)
